package com.cocostudio.erpapp;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.util.HashMap;
import java.util.Map;




import com.cocostudio.erpapp.R;
import com.cocostudio.erpapp.utils.WebServiceUtils;
import com.cocostudio.erpapp.vo.WSRealTimeSalesResult;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class TestActivity extends Activity {
    private static final String TAG = TestActivity.class.getSimpleName();

    private WebView webView;
    
    private String data;
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detail_result);
        
        
        initView();
        
        
    }

    
    
    public String getFromAssets(String fileName){ 
        String Result="";
        try { 
             InputStreamReader inputReader = new InputStreamReader( getResources().getAssets().open(fileName) ); 
            BufferedReader bufReader = new BufferedReader(inputReader);
            String line="";
             Result="";
            while((line = bufReader.readLine()) != null)
                Result += line;
        } catch (Exception e) { 
            e.printStackTrace(); 
        }
        return Result;
    } 
    
    private void initView() {
        
        StringBuffer sb = new StringBuffer(); 
        sb.append("<div>官网实力榜：全胜步行者居榜首 热火第四火箭第八</div>"); 
        sb.append("<ul>"); 
        sb.append("<li>1、印第安纳步行者(7胜0负)</li>"); 
        sb.append("<li>2、圣安东尼奥马刺(6胜1负)</li>"); 
        sb.append("<li>3、俄克拉荷马城雷霆(5胜1负)</li>"); 
        sb.append("<li>4、迈阿密热火(4胜3负)</li>"); 
        sb.append("</ul>"); 
        data=sb.toString(); 
        
        
        // TODO Auto-generated method stub
      webView = (WebView) findViewById(R.id.detail_result_webview);
   
        
        //webView.loadUrl("file:///android_asset/ftl/realtime_sales.html");
        String htmldata = getFromAssets("ftl/realtime_sales.html");
        //String  htmldata = getFromAssets("car_result.html");
        
        StringWriter htmlcontent=new StringWriter();
        //组织网页内容
        try {
            //从接口获取信息
            //WSRealTimeSalesResult result1 = WebServiceUtils.WS_RealTimeSales("010101","000001","兰扣","");
            
           // Map<String,Object> root = new HashMap<String, Object>();
          //  root.put("item", result1);
            
            //Template temp = fmk_cfg.getTemplate("ftl/realtime_sales.html");
            //temp.process(root, htmlcontent);
            
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }  
        webView.loadDataWithBaseURL("file:///android_asset/", htmlcontent.toString(), "text/html", "UTF-8", null); 
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

}
